package com.it.client;

import com.it.interceptor.ClientLoginInterceptor;
import org.apache.cxf.endpoint.Client;
import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;

public class CXFDynamicClient {
    private static final String ADDRESS = "http://localhost:8080/services/MessageService?wsdl"; // WebService服务地址

    public static void main(String[] args) throws Exception {
        JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
        Client client = dcf.createClient(ADDRESS);
        client.getOutInterceptors().add(new ClientLoginInterceptor("admin","123456"));
        String message = "dynamic";
        client.invoke("echo", message);
    }
}